package one.stand.controller;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.exception.ParamException;
import one.stand.model.ResultModel;
import one.stand.request.essay.*;
import one.stand.response.essay.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Map;

/**
 * 获客文章类型相关业务
 * @author luoyang
 * @date 2020/5/7 11:38
 */
@RestController
@RequestMapping("crmApi/customerEssay")
@Api(description = "获客文章",tags="获客文章")
public class CustomerEssayController extends BaseController{

    /**
     * 员工数据查询
     * @param request
     * @return
     */
    @ApiOperation(value = "员工数据查询")
    @ApiController(isLogin = true, company = true,card = true,paramClass = EssayStaffDataRequest.class)
    @PostMapping("queryStaffData")
    public ResultModel queryStaffData(@RequestAttribute  EssayStaffDataRequest request){
        return crmFegin.queryStaffData(request);
    }

    /**
     * 添加或更新获客文章员工数据
     * @param request
     * @return
     */
    @ApiOperation(value = "添加或更新获客文章员工数据")
    @ApiController(isLogin = false, company = true,card = true,paramClass = EssayStaffDataFrom.class)
    @PostMapping("addStaffData")
    public ResultModel<Boolean> addStaffData(@RequestAttribute  EssayStaffDataFrom request){
        return crmFegin.addStaffData(request);
    }

    /**
     * 添加或更新访客数据
     * @param request
     * @return
     */
    @ApiOperation(value = "添加或更新访客数据")
    @ApiController(isLogin = false, company = true,card = true,paramClass = EssayVisitorsDataForm.class)
    @PostMapping("addVisitorsData")
    public ResultModel<Boolean> addVisitorsData(@RequestAttribute  EssayVisitorsDataForm request) throws ParamException {
        return crmFegin.addVisitorsData(request);
    }


    /**
     * 添加或更新员工分享数据
     * @param request
     * @return
     */
    @ApiOperation(value = "添加或更新员工分享数据")
    @ApiController(isLogin = true, company = true,card = true,paramClass = EssayRecordForm.class)
    @PostMapping("addShareRecordData")
    public ResultModel<Boolean> addShareRecordData(@RequestAttribute  EssayRecordForm request) throws ParamException {
        return crmFegin.addShareRecordData(request);
    }

    /**
     * 员工分享详情
     * @param request
     * @return
     */
    @ApiOperation(value = "员工分享详情")
    @ApiController(isLogin = true, company = true,card = true,paramClass = EssayShareDetailRequest.class)
    @PostMapping("queryStaffShareDetail")
    public ResultModel queryStaffShareDetail(@RequestAttribute  EssayShareDetailRequest request){
        return crmFegin.queryStaffShareDetail(request);
    }


    /**
     * 访客数据查询
     * @param request
     * @return
     */
    @ApiOperation(value = "访客数据查询")
    @ApiController(isLogin = true, company = true,card = true,paramClass = EssayVisitorsDataRequest.class)
    @PostMapping("queryVisitorsData")
    public ResultModel<List<EssayVisitorsDataResponse>> queryVisitorsData(@RequestAttribute  EssayVisitorsDataRequest request){
        return crmFegin.queryVisitorsData(request);
    }


    /**
     * 文章中心 ，按条件查询 已分享的 或者企业文库  ,企业文库里面的文章只要分享过的都会出现在已分享，不算企业文库
     * @param request
     * @return
     */
    @ApiOperation(value = "文章中心 ，按条件查询 已分享的 或者企业文库  ,企业文库里面的文章只要分享过的都会出现在已分享，不算企业文库")
    @ApiController(isLogin = true, company = true,card = true,paramClass = DynamicQuery.class)
    @PostMapping("queryDynamicData")
    public ResultModel queryDynamicData(@RequestAttribute  DynamicQuery request){
        return crmFegin.queryDynamicData(request);
    }

    /**
     *
     * @param request
     * @return
     */
    @PostMapping("deleteByDynamicId")
    @ApiOperation(value = "删除已经分享的文章")
    @ApiController(isLogin = true, company = true,card = true,paramClass = CompanyDynamicsQuery.class)
    public ResultModel deleteByDynamicId(@RequestAttribute CompanyDynamicsQuery request){
        return crmFegin.deleteByDynamicId(request);
    }

    /**
     * 查询文章访客详情 倒叙排列
     * @param request
     * @return
     */
    @ApiOperation(value = "访客详情 倒叙排列")
    @ApiController(isLogin = true, company = true,card = true,paramClass = VisitorsDetailQuery.class)
    @PostMapping("queryDynamicVisitors")
    public ResultModel<DynamicModelResponse> queryDynamicVisitors(@RequestAttribute  VisitorsDetailQuery request){
        return crmFegin.queryDynamicVisitors(request);
    }


    /**
     * 按商品分类查询公司下的商品
     * @param request
     * @return
     */
    @ApiOperation(value = "按商品分类查询公司下的商品")
    @ApiController(isLogin = true, company = true,card = true,paramClass = GoodsQuery.class)
    @PostMapping("queryCompanyGoods")
    public ResultModel<List<CompanyGoodsTypeResponse>> queryCompanyGoods(@RequestAttribute  GoodsQuery request){
        return crmFegin.queryCompanyGoods(request);
    }

    /**
     * 查询公司下的文章
     * @param request
     * @return
     */
    @ApiOperation(value = "查询公司下的文章")
    @ApiController(isLogin = true, company = true,card = true,paramClass = CompanyDynamicsQuery.class)
    @PostMapping("queryCompanyDynamics")
    public ResultModel queryCompanyDynamics(@RequestAttribute  CompanyDynamicsQuery request){
        return crmFegin.queryCompanyDynamics(request);
    }


    /**
     * 查询文章详情
     * @param request
     * @return
     */
    @ApiOperation(value = "文章分享详情")
    @ApiController(isLogin = true, company = true,card = true,paramClass = CompanyDynamicsQuery.class)
    @PostMapping("queryCompanyDynamicById")
    public ResultModel<DynamicDetailResponse> queryCompanyDynamicById(@RequestAttribute  CompanyDynamicsQuery request){
        return crmFegin.queryCompanyDynamicById(request);
    }


    /**
     * 添加获客文章任务
     * @param request
     * @return
     */
    @ApiOperation(value = "创建任务")
    @ApiController(isLogin = true, company = true,card = true,paramClass = TaskCustomerForm.class)
    @PostMapping("addTaskCustomer")
    public ResultModel<Boolean> addTaskCustomer(@RequestAttribute  TaskCustomerForm request) throws ParamException {
        return crmFegin.addTaskCustomer(request);
    }

    /**
     * 查询获客文章任务
     * @param request
     * @return
     */
    @ApiOperation(value = "查询获客文章任务")
    @ApiController(isLogin = true, company = true,card = true,paramClass = TaskCustomerQuery.class)
    @PostMapping("queryTaskCustomer")
    public ResultModel<TaskCustomerResponse> queryTaskCustomer(@RequestAttribute  TaskCustomerQuery request) throws ParamException {
        return crmFegin.queryTaskCustomer(request);
    }

    /**
     * 查询我的任务列表
     * @param request
     * @return
     */
    @ApiOperation(value = "查询我的任务列表")
    @ApiController(isLogin = true, company = true,card = true,paramClass = MyTaskQuery.class)
    @PostMapping("queryMyTask")
    public ResultModel queryMyTask(@RequestAttribute  MyTaskQuery request) throws ParamException {
        return crmFegin.queryMyTask(request);
    }

    /**
     * 查询我的任务详情
     * @param request
     * @return
     */
    @ApiOperation(value = "查询任务详情")
    @ApiController(isLogin = true, company = true,card = true,paramClass = MyTaskDetailQuery.class)
    @PostMapping("queryMyTaskDetail")
    public ResultModel<MyTaskResponse> queryMyTaskDetail(@RequestAttribute  MyTaskDetailQuery request) throws ParamException {
        return crmFegin.queryMyTaskDetail(request);
    }

    /**
     * 更新我的任务状态 state为空则更新查看状态 不为空则更新任务状态
     * @param request
     * @return
     */
    @ApiOperation(value = "更新我收到的任务状态 state为空则更新查看状态 不为空则更新任务状态")
    @ApiController(isLogin = true, company = true,card = true,paramClass = UpdateMyTaskFrom.class)
    @PostMapping("updateMyTaskState")
    public ResultModel<Boolean> updateMyTaskState(@RequestAttribute  UpdateMyTaskFrom request) throws ParamException {
        return this.crmFegin.updateMyTaskState(request);
    }


    /**
     * 更新我发布的任务状态 state为空则更新查看状态 不为空则更新任务状态
     * @param request
     * @return
     */
    @ApiOperation(value = "更新我发布的任务状态 state为空则更新查看状态 不为空则更新任务状态")
    @ApiController(isLogin = true, company = true,card = true,paramClass = UpdateMyTaskFrom.class)
    @PostMapping("updateMyPubTaskState")
    public ResultModel<Boolean> updateMyPubTaskState(@RequestAttribute UpdateMyTaskFrom request) throws ParamException {
        return this.crmFegin.updateMyPubTaskState(request);
    }

    /**
     * 转载文章解析
     * @param request
     * @return
     * @throws ParamException
     */
    @PostMapping("reprintArticle")
    @ApiOperation(value = "转载文章解析")
    @ApiController(isLogin = true,company = true,card = true,paramClass = ReprintArticleForm.class)
    public ResultModel<ReprintArticleResponse> reprintArticle(@RequestAttribute  ReprintArticleForm request){
        return crmFegin.reprintArticle(request);
    }


    /**
     * h5文章查询员工信息
     * @param request
     * @return
     */
    @ApiOperation(value = "h5文章查询员工信息")
    @PostMapping("getDynamic")
    @ApiController(isLogin = false,company = true,card = true,paramClass = H5GetDynamic.class)
    public ResultModel<Map<String,Object>> getDynamic(@RequestAttribute H5GetDynamic request){
        return crmFegin.getDynamic(request);
    }
}
